package com.hualan.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.sfzy.entity.Artical;
import com.hualan.sfzy.entity.ArticalClassification;
import com.hualan.sfzy.mapper.ArticalClassificationMapper;
import com.hualan.sfzy.mapper.ArticalMapper;
import com.hualan.sfzy.service.ArticalClassificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ArticalClassificationServiceImpl implements ArticalClassificationService {
    @Autowired
    private ArticalClassificationMapper articalClassificationMapper;

    @Override
    public int add(ArticalClassification entity) {
        return 0;
    }

    @Override
    public int addSelective(ArticalClassification articalClassification){
        return articalClassificationMapper.insert(articalClassification);
    }

    @Override
    public int edit(ArticalClassification entity) {
        return articalClassificationMapper.update(entity);
    }

    @Override
    public int remove(Integer id) {
        return articalClassificationMapper.delete(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return articalClassificationMapper.deleteBatch(ids);
    }

    @Override
    public List<ArticalClassification> find() {
        return Collections.emptyList();
    }

    @Override
    public List<ArticalClassification> findAll(){
        return articalClassificationMapper.selectAll();
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, ArticalClassification entity) {
        PageHelper.startPage(pageNum,pageSize);
        List<ArticalClassification> list = articalClassificationMapper.fuzzySelect(entity);
        PageInfo<ArticalClassification> pageInfo = new PageInfo<>(list);
        Map<String, Object> map = new HashMap<>();
        map.put("pageInfo", pageInfo);
        return map;
    }

    @Override
    public ArticalClassification findById(Integer id) {
        return articalClassificationMapper.selectById(id);
    }
}
